//Hakko revenge #include "msp430G2553.h" #include "math.h" //============ Define preset values here #define firmware_version 4.4 // This will show up on the Info screen #define hardware_version 3.2 // This will show up on the Info screen - The first char means A,B or C versions #define max_set_temp 430 // [*C] maximum temperature you can set #define min_set_temp 70 // [*C] minimum temperature you can set #define max_time 390 // [s] maximum time you can set before the soldering iron will drop to st by temperature #define min_time 60 // [s] minimum time you can set before the soldering iron will drop to st by temperature #define default_time 300 // [s] default time until the soldering iron will drop to st by temperature #define default_st_by_temp 195 // [*C] default stand by temperature #define default_solder_temp 365// [*C] default soldering temperature #define default_sound 2 // default sound setting #define default_light 55 // PWM default backlight setting #define tip_ol_value 0.6 // [A] less than this current on the heating element will trigger the error #define tip_sc_value 5.0 // [A] more than this current on the heating element will trigger the error #define tip_range_temp 620 // [*C] more than this temp value triggers an error #define th_shut_down 85 // [*C] thermal shut down - PCB temp value at which the soldering station stops the heating #define over_voltage_value 29 // [V] exceeding this input voltage will trigger the error //=========== Define general values here #define EN_heater BIT0 #define Clear 0x00 #define D4 BIT2 // LCD bits definition #define D5 BIT3 #define D6 BIT4 #define D7 BIT5 #define RS BIT0 #define EN BIT1 #define ERR_OL BIT0 // Open load error. Signifies disconnected aviator plug or heating element #define ERR_DT BIT1 // Damaged tip error (taking too much current or too less). Signifies poor contact, short circuit, loose wires or burned heating element #define ERR_OT BIT2 // Over temp error. Signifies that the motherboard is too hot #define ERR_OV BIT3 // Over voltage error. Signifies that the input voltage is above the safe limit. int array_div_mod[4]; float medc[5],medv[5],medbt[5],medtt[5]; const unsigned char array_LCD_config_string[14] = {D5+D4,D5+D4,D5+D4,D5,D5,D7,Clear,D7+D6,Clear,D7+D6+D5+D4,Clear,D4,Clear,D4}; const unsigned char array_special_char[80] = {RS,RS,RS,D4+RS,RS,D5+D4+RS,RS,D6+D5+D4+RS,RS,D5+D4+RS,RS,D6+D4+RS,RS,RS+D7,RS+D4,RS, D4+RS,RS+D6+D7,D4+RS,D7+RS+D5,D4+RS,D4+RS+D7,D4+RS,D4+RS,RS,D4+RS,RS,RS,RS,RS,RS,RS, RS,RS+D6,RS,D7+RS+D6,RS+D4,D5+RS+D7+D6,RS,D7+D6+D4+RS,RS,D6+D4+RS,RS+D4,RS+D4,RS+D4,RS+D7+D4,RS,RS+D7+D6+D5, RS,RS+D6,RS,D5+RS+D6,RS,D5+RS+D7+D6+D4,RS+D4,D6+D5+RS,RS+D4,D6+RS,RS+D4,RS+D4,RS,RS+D7+D4+D5,RS,RS+D6+D5, RS,RS+D6,RS+D4,D5+RS+D6+D7+D4,RS,D5+RS+D7+D6,RS,D6+RS,RS,RS,RS,RS+D7+D6+D5,RS,RS+D7+D5,RS+D4,RS+D6+D5+D4}; const unsigned char bck_ground_logo1[32] = {' ',' ','H','a','k','k','o',' ',' ','R','e','v','e','n','g','e',' ','M','a','r','i','u','s',' ',' ','T','a','c','i','u','c',' '}; const unsigned char bck_ground_main[16] = {' ',' ','M','a','i','n',' ',' ',0x00,0x01,' ',' ',' ',' ',' ',0x03}; const unsigned char bck_ground_solder[16] = {' ','S','o','l','d','e','r',' ',0x00,0x01,' ',' ',0x04,' ',' ',0x03}; const unsigned char bck_ground_up[16] = {'U','p',' ','t','e','m','p',' ',0x02,' ',' ',' ',0x04,' ',' ',0x03}; const unsigned char bck_ground_low[8] = {'L','o','w',' ','t','e','m','p'}; const unsigned char bck_ground_time[8] = {'T','i','m','e',' ','h','o','t'}; const unsigned char bck_ground_sound[8] = {' ','S','o','u','n','d',' ',' '}; const unsigned char bck_ground_light[8] = {'B','k',' ','l','i','g','h','t'}; const unsigned char bck_ground_default[16] = {'D','e','f','a','u','l','t',' ','A','l','l',' ','s','e','t',' '}; const unsigned char bck_ground_info[16] = {' ',' ','I','n','f','o',' ',' ',0x02,' ',' ',' ',0x04,' ',' ',' '}; const unsigned char bck_ground_subsolder[16] = {'T','=',' ',' ',' ',0xDF,'C',' '}; const unsigned char bck_ground_retmain[8] = {'M','a','i','n',' ',0x04,' ',0x03}; const unsigned char bck_ground_retsol[8] = {0x02,' ',0x04,' ','B','a','c','k'}; const unsigned char err_plug[8] = {'E','r','r',' ','p','l','u','g'}; const unsigned char err_tip[8] = {'E','r','r',' ','t','i','p',' '}; const unsigned char err_over_heat[8] = {'O','v','r',' ','h','e','a','t'}; const unsigned char err_over_volt[8] = {'O','v','r',' ','v','o','l','t'}; const unsigned char errors_multiple[8] = {' ','E','r','r','o','r','s',' '}; unsigned char match,match_low,err; int temp2,i,n,tenthsp,unitsp,tenthsv,unitsv,decimal1v,menu; int tenthsbt,unitsbt,tenthstt,unitstt,decimal1tt; int menumem,menu_ps,buton,rotE,beep_l,beep_f,PWM_test,temp_preset,low_temp_preset,time_hot_preset,sound_preset,light_preset; int IntVolt,IntCur,IntBtemp,IntTtemp,temp_reference,st_by_timer,info,count_m; float btemp_val_c,ttemp_val_c,volt_val_c,cur_val_c,volt_val,cur_val,btemp_val,ttemp_val,ttemp_val_disp,m,d_power; float convert_volt(float); float convert_cur(float); float convert_btemp(float); float convert_ttemp(float); float bucla_div_mod(float); void ADC_sampling(int); void ADC_convert(int); void ADC_average(int); void ADC_div_mod(int); void move_cursor_xy(int,int); void configure_lcd(int); void display_char(unsigned char); void write_flash_data(int); void read_flash_data(int); int debouncing_la_actionare_rotire(int); int debouncing_la_revenire_rotire(int); int debouncing_but(int); void delay_time(int); void delay_long(int); void delay_extra_long(int); void create_custom_char(int); void strobe_data_p2(int); void cls(int); void draw_Logo(int); void draw_info_screen(int); void draw_main_menu_screen(int); void draw_solder_screen(int); void draw_time_hot_screen(int); void draw_sound_screen(int); void draw_light_screen(int); void draw_default(int); void draw_low_temp_screen(int); void draw_hi_temp_screen(int); void draw_sub_solder(int); void draw_sub_solder_mm(int); void draw_sub_solder_ret(int); void beep_lf(int,int); void main(void){ WDTCTL = WDTPW + WDTHOLD; // disable watch dog timer DCOCTL = CALDCO_16MHZ; // set internal oscillator at 16MHz BCSCTL1 = CALBC1_16MHZ; // set internal oscillator at 16MHz P1OUT = Clear; P2OUT = Clear; P3OUT = Clear; P1DIR = 0x83; // 1000 0011 P2DIR = 0xFF; // 1111 1111 P3DIR = 0xF8; // 1111 1000 //--------------------config ADC ADC10CTL1 |= INCH_2; //continuous sample mode, CH2 // CONSEQ1 + INCH_2 ADC10CTL0 |= ADC10SHT_2 + ADC10ON + MSC; //sample and hold time, adc on, cont. sample ADC10AE0 |= 0x04; // select channel A2 ADC10CTL0 |= ADC10SC + ENC; // start conversions read_flash_data(0); err = 0; menu = 1; //--------------------config PWM P3SEL |= (BIT3); // P3.3 Select as TA1 output TA1CCR0 = 5000; TA1CCR2 = (50 * light_preset); TA1CCTL2 |= OUTMOD_7; //toggle TA1CTL |= TASSEL_2 + MC_1 +ID_3; //smclk div/8 upmode. configure_lcd(0); draw_Logo(0); beep_lf(100,1000); beep_lf(100,1200); beep_lf(100,1500); beep_lf(100,1800); for(n=0;n<6;n++){ ADC_sampling(0); ADC_convert(0); ADC_average(0); } ADC_div_mod(0); for(;;) { do{ //============================================================ select menu loop ================ if (menu == 0){ draw_main_menu_screen(0); } if (menu == 1){ draw_solder_screen(0); } if (menu == 2){ draw_hi_temp_screen(0); } if (menu == 3){ draw_low_temp_screen(0); } if (menu == 4){ draw_time_hot_screen(0); } if (menu == 5){ draw_sound_screen(0); } if (menu == 6){ draw_light_screen(0); } if (menu == 7){ draw_info_screen(0); } if (menu == 8){ draw_default(0); } rotE = debouncing_la_actionare_rotire(rotE); if((rotE == 4) and (menu < 8)){ menu++; beep_lf(100,1000); } if((rotE == 2) and (menu > 1)){ menu--; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ); //========================================== select menu loop END ================ buton = debouncing_but(buton); menumem = menu; if(menu == 1){ //=========================================== Solder menu 1 ========================= draw_sub_solder(0); m = temp_preset; m = m/10; bucla_div_mod(m); move_cursor_xy(3,1); //---display target shortly display_char(array_div_mod[0] + 0x30); display_char(array_div_mod[1] + 0x30); display_char(array_div_mod[2] + 0x30); move_cursor_xy(9,2); delay_extra_long(0); st_by_timer = 80*time_hot_preset; match = 0; do{ if(PWM_test == 0){ PWM_test = 1; n = 36; //30 } else{ PWM_test = 0; n = 12; //10 } //------------------------------------------ temp regulating loop do{ ADC_sampling(0); ADC_convert(0); ADC_average(0); //------------------------------------------------check for errors if((cur_val < tip_ol_value)or(cur_val > tip_sc_value)){ err |= ERR_DT; beep_lf(1,1000); } else{ err &= ~(ERR_DT); } if(volt_val > over_voltage_value){ err |= ERR_OV; beep_lf(1,1000); } else{ err &= ~(ERR_OV); } if(ttemp_val > (tip_range_temp/10)){ err |= ERR_OL; beep_lf(1,1000); } else{ err &= ~(ERR_OL); } if(btemp_val > th_shut_down){ err |= ERR_OT; beep_lf(1,1000); } else{ err &= ~(ERR_OT); } //-------------------------------reset handle timer acording to moovement temp2 = P1IN; buton = (temp2 &= 0x40); // 0100 0000 mask if (buton == 0){ st_by_timer = 104*time_hot_preset; } if(st_by_timer > 1){ temp_reference = temp_preset; match_low = 0; st_by_timer--; } else{ temp_reference = low_temp_preset; match=0; } if((match == 1) or (match_low == 1)){ ttemp_val_disp = ((ttemp_val + (temp_reference/5)) / 3); //this average function makes the displayed value les flickery } else{ ttemp_val_disp = ttemp_val; } //---------------------------------- adjusting temp acording to feedback if((ttemp_val < (temp_reference/10))and(PWM_test == 1)){ P1OUT |= EN_heater; // Enable heater = 1 move_cursor_xy(8,1); display_char('+'); } else{ P1OUT &= ~(EN_heater); // Heater = 0 move_cursor_xy(8,1); display_char(' '); } if((match == 0)and((ttemp_val*10) > (temp_preset+110))){ beep_lf(100,1800); // beep when reach temperature beep_lf(100,1500); beep_lf(100,1200); beep_lf(100,1000); match = 1; } if((match_low == 0)and((ttemp_val*10) < (low_temp_preset))){ match_low = 1; } n--; }while (n != 0); //-------------------------------End of temp regulating loop ADC_div_mod(0); //------------------------------------------------------ display values move_cursor_xy(3,1); display_char(tenthstt + 0x30); display_char(unitstt + 0x30); display_char(decimal1tt + 0x30); if(err > 0){ move_cursor_xy(1,2); if(err == 1){ for(i=0;i<8;i++){ display_char(err_plug[i]); } } if(err == 2){ for(i=0;i<8;i++){ display_char(err_tip[i]); } } if(err == 4){ for(i=0;i<8;i++){ display_char(err_over_heat[i]); } } if(err == 8){ for(i=0;i<8;i++){ display_char(err_over_volt[i]); } } if((err == 3)or(err == 5)or(err == 6)or(err == 7)or(err > 8)){ move_cursor_xy(1,2); for(i=0;i<8;i++){ display_char(errors_multiple[i]); } } } else{ move_cursor_xy(1,2); display_char(tenthsp + 0x30); display_char(unitsp + 0x30); display_char('W'); display_char(' '); display_char(tenthsbt + 0x30); display_char(unitsbt + 0x30); display_char(0xDF); display_char('C'); } //--------------------------------------------- ------------------------ submenu loop - temp2 = P3IN; buton = (temp2 &= 0x01); if (buton == 0){ P1OUT &= ~(EN_heater); // Heater = 0 move_cursor_xy(8,1); display_char(' '); menu_ps = 1; draw_sub_solder_mm(0); beep_lf(100,1000); buton = debouncing_but(buton); do{ rotE = debouncing_la_actionare_rotire(rotE); if((rotE == 4) and (menu_ps < 2)){ menu_ps++; beep_lf(100,1000); } if((rotE == 2) and (menu_ps > 1)){ menu_ps--; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); if (menu_ps == 1){ draw_sub_solder_mm(0); } if (menu_ps == 2){ draw_sub_solder_ret(0); } temp2 = P3IN; buton = (temp2 &= 0x01); }while(buton != 0); } if((menu_ps == 2)and(buton == 0)){ //----------------submenu Return buton = debouncing_but(buton); beep_lf(100,1000); menu = menumem; draw_sub_solder(0); } if((menu_ps == 1)and(buton == 0)){ //--------submenu Return to main menu buton = debouncing_but(buton); beep_lf(100,1000); menu = 0; } }while ( menu == menumem ) ; } // ==================================================================== Solder menu 1 END ========== if(menu == 2){ //=============================================== Hi temp menu 2 ============= cls(2); do{ m = temp_preset; m = m/10; bucla_div_mod(m); move_cursor_xy(3,2); display_char(array_div_mod[0] + 0x30); display_char(array_div_mod[1] + 0x30); display_char(array_div_mod[2] + 0x30); display_char(0xDF); display_char('C'); move_cursor_xy(9,2); rotE = debouncing_la_actionare_rotire(rotE); if((rotE == 4) and (temp_preset < max_set_temp)){ temp_preset = temp_preset+5; beep_lf(100,1000); } if((rotE == 2) and (temp_preset > low_temp_preset)){ temp_preset = temp_preset-5; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; beep_lf(100,1000); write_flash_data(0); buton = debouncing_but(buton); } //=============================================== Hi temp menu 2 END ============= if(menu == 3){ //=============================================== Low temp menu 3 ============= cls(2); do{ m = low_temp_preset; m = m/10; bucla_div_mod(m); move_cursor_xy(3,2); display_char(array_div_mod[0] + 0x30); display_char(array_div_mod[1] + 0x30); display_char(array_div_mod[2] + 0x30); display_char(0xDF); display_char('C'); move_cursor_xy(9,2); rotE = debouncing_la_actionare_rotire(rotE); if((rotE == 4) and (low_temp_preset < max_set_temp)){ low_temp_preset = low_temp_preset+5; beep_lf(100,1000); } if((rotE == 2) and (low_temp_preset > min_set_temp)){ low_temp_preset = low_temp_preset-5; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; beep_lf(100,1000); write_flash_data(0); buton = debouncing_but(buton); } //=============================================== low temp menu 3 END ============= if(menu == 4){ //=============================================== Time hot menu 4 ============= cls(2); do{ m = time_hot_preset; m = m/10; bucla_div_mod(m); move_cursor_xy(3,2); display_char(array_div_mod[0] + 0x30); display_char(array_div_mod[1] + 0x30); display_char(array_div_mod[2] + 0x30); display_char('s'); move_cursor_xy(9,2); rotE = debouncing_la_actionare_rotire(rotE); if((rotE == 4) and (time_hot_preset < max_time)){ time_hot_preset = time_hot_preset+5; beep_lf(100,1000); } if((rotE == 2) and (time_hot_preset > min_time)){ time_hot_preset = time_hot_preset-5; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; beep_lf(100,1000); write_flash_data(0); buton = debouncing_but(buton); } //=============================================== Time hot menu 4 END ============= if(menu == 5){ //=============================================== Sound menu 5 ============= cls(2); do{ m = sound_preset; bucla_div_mod(m); move_cursor_xy(3,2); display_char(array_div_mod[1] + 0x30); move_cursor_xy(9,2); rotE = debouncing_la_actionare_rotire(rotE); if((rotE == 4) and (sound_preset < 5)){ sound_preset++; } if((rotE == 2) and (sound_preset > 0)){ sound_preset--; } beep_lf(100,1000); rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; beep_lf(100,1000); write_flash_data(0); buton = debouncing_but(buton); } //=============================================== Sound menu 5 END ============= if(menu == 6){ //=============================================== Back light menu 6 ============= cls(2); do{ m = light_preset; m = m/10; bucla_div_mod(m); move_cursor_xy(3,2); display_char(array_div_mod[0] + 0x30); display_char(array_div_mod[1] + 0x30); display_char(array_div_mod[2] + 0x30); display_char(' '); display_char('%'); move_cursor_xy(9,2); rotE = debouncing_la_actionare_rotire(rotE); if((rotE == 4) and (light_preset < 100)){ light_preset = light_preset+5; } if((rotE == 2) and (light_preset > 0)){ light_preset = light_preset-5; } TA1CCR2 = (50 * light_preset); beep_lf(100,1000); rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; beep_lf(100,1000); write_flash_data(0); buton = debouncing_but(buton); } //=============================================== Back light menu 6 END ============= if(menu == 7){ //=============================================== Info menu 7 =============== info = 1; do{ if(info == 1){ m = firmware_version; bucla_div_mod(m); move_cursor_xy(1,2); display_char(' '); display_char('S'); display_char('W'); display_char('-'); display_char('V'); display_char(array_div_mod[1] + 0x30); display_char('.'); display_char(array_div_mod[2] + 0x30); } if(info == 2){ m = hardware_version; bucla_div_mod(m); move_cursor_xy(1,2); display_char(' '); display_char('H'); display_char('W'); display_char('-'); display_char('V'); display_char(array_div_mod[1] + 0x30); display_char('.'); display_char(array_div_mod[2] + 0x30); } if(info == 3){ move_cursor_xy(1,2); display_char(' '); display_char('U'); display_char('='); display_char(tenthsv + 0x30); display_char(unitsv + 0x30); display_char('.'); display_char(decimal1v + 0x30); display_char('V'); } if(info == 4){ move_cursor_xy(1,2); display_char('P'); display_char('C'); display_char('B'); display_char('='); display_char(tenthsbt + 0x30); display_char(unitsbt + 0x30); display_char(0xDF); display_char('C'); } if(info == 5){ move_cursor_xy(1,2); display_char('T'); display_char('i'); display_char('p'); display_char(tenthstt + 0x30); display_char(unitstt + 0x30); display_char(decimal1tt + 0x30); display_char(0xDF); display_char('C'); } rotE = debouncing_la_actionare_rotire(rotE); if((rotE == 4) and (info < 5)){ info++; beep_lf(100,1000); } if((rotE == 2) and (info > 1)){ info--; beep_lf(100,1000); } rotE = debouncing_la_revenire_rotire(rotE); temp2 = P3IN; buton = (temp2 &= 0x01); }while ( buton != 0 ) ; beep_lf(100,1000); buton = debouncing_but(buton); } //=============================================== Info menu 7 END ============= if(menu == 8){ //=============================================== Default menu 8 ============= move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_default[i]); } beep_lf(100,1000); delay_extra_long(0); temp_preset = default_solder_temp; low_temp_preset = default_st_by_temp; time_hot_preset = default_time; sound_preset = default_sound; light_preset = default_light; write_flash_data(0); TA1CCR2 = (50 * light_preset); buton = debouncing_but(buton); } //=============================================== Default menu 8 END ============= } } //--------------------------------------------------------------------------------------------------------------------------------------- //----------------- FUNCTIONS ----------- PROCEDURES ----------- FUNCTIONS ----------- PROCEDURES ----------- FUNCTIONS ------- //--------------------------------------------------------------------------------------------------------------------------------------- void ADC_sampling(int){ //--------------------------------- Sample the ADC ports for values //-------------------------------------------------read board temp ADC10CTL1 &= ~(INCH_2); //disable continuous sample mode, CH2 ADC10CTL1 |= INCH_5; //continuous sample mode, CH5 ADC10AE0 |= 0x20; // select channel A5 //0010 0000 ADC10CTL0 |= ADC10SC + ENC; // start conversions delay_time(50); IntBtemp = ADC10MEM; ADC10CTL0 &= ~(ADC10SC + ENC); // stop conversions //-------------------------------------------------read tip temp ADC10CTL1 &= ~(INCH_5); //disable continuous sample mode, CH5 ADC10CTL1 |= INCH_4; //continuous sample mode, CH4 ADC10AE0 |= 0x10; // select channel A4 //0001 0000 ADC10CTL0 |= ADC10SC + ENC; // start conversions delay_time(50); IntTtemp = ADC10MEM; ADC10CTL0 &= ~(ADC10SC + ENC); // stop conversions //-------------------------------------------------read current ADC10CTL1 &= ~(INCH_4); //disable continuous sample mode, CH4 ADC10CTL1 |= INCH_3; //continuous sample mode, CH3 ADC10AE0 |= 0x08; // select channel A3 //0000 1000 ADC10CTL0 |= ADC10SC + ENC; // start conversions delay_time(50); IntCur = ADC10MEM; ADC10CTL0 &= ~(ADC10SC + ENC); // stop conversions //-------------------------------------------------read voltage ADC10CTL1 &= ~(INCH_3); //disable continuous sample mode, CH3 ADC10CTL1 |= INCH_2; //continuous sample mode, CH2 ADC10AE0 |= 0x04; // select channel A2 //0000 0100 ADC10CTL0 |= ADC10SC + ENC; // start conversions delay_time(50); IntVolt = ADC10MEM; ADC10CTL0 &= ~(ADC10SC + ENC); // stop conversions } void ADC_convert(int){ //---------------------------------- Convert the sampled values btemp_val_c = convert_btemp (IntBtemp); if(PWM_test == 0){ ttemp_val_c = convert_ttemp (IntTtemp); volt_val_c = convert_volt (IntVolt); } if((IntCur > 0x05)and(PWM_test == 1)){ cur_val_c = convert_cur (IntCur); } d_power = ((volt_val*cur_val*0.75) * (ttemp_val/43)); //d_power = cur_val; // replace the line above with this for //reading the current on the screen instead of power for calibration } void ADC_average(int){ //----------------------------- Average last 5 samples for all measurements if (IntVolt > 0x00){ for(i=0; i<4; i++){ medv[i] = medv[i+1]; medc[i] = medc[i+1]; medbt[i] = medbt[i+1]; medtt[i] = medtt[i+1]; } medv[4] = volt_val_c; medc[4] = cur_val_c; medbt[4] = btemp_val_c; medtt[4] = ttemp_val_c; } volt_val = ((medv[0]+medv[1]+medv[2]+medv[3]+medv[4])/5); cur_val = ((medc[0]+medc[1]+medc[2]+medc[3]+medc[4])/5); btemp_val = ((medbt[0]+medbt[1]+medbt[2]+medbt[3]+medbt[4])/5); ttemp_val = ((medtt[0]+medtt[1]+medtt[2]+medtt[3]+medtt[4])/5); //ttemp_val_disp = ttemp_val; //((ttemp_val + (temp_reference/10)) / 2); //this average function makes the displayed value les flickery } void ADC_div_mod(int){ //------------------------------ Loop for div/mod voltage Values bucla_div_mod(volt_val); tenthsv = array_div_mod[0]; unitsv = array_div_mod[1]; decimal1v = array_div_mod[2]; //------------------------------ Loop for div/mod Power Values bucla_div_mod(d_power); tenthsp = array_div_mod[0]; unitsp = array_div_mod[1]; //----------------------------- Loop for div/mod Board temp Values bucla_div_mod(btemp_val); tenthsbt = array_div_mod[0]; unitsbt = array_div_mod[1]; //---------------------------- Loop for div/mod Tip temp values Values bucla_div_mod(ttemp_val_disp); tenthstt = array_div_mod[0]; unitstt = array_div_mod[1]; decimal1tt = array_div_mod[2]; } void delay_time (int delay){ //----------------------------------------- Delay--------------------- do delay--; while (delay != 0); } void delay_long (int){ //--------------------------------------- long Delay ------------------ int j; j = 200; do{ delay_time(5000); j--; }while (j != 0); } void delay_extra_long (int){ //------------------------------extra long Delay ------------------ count_m = 6; do{ delay_long(0); count_m --; }while(count_m !=0); } float convert_volt (float IntVolt){ // ------------------------Voltage conversion float voltage,ua2,raport_divizor,r2,r1; r1 = 10000; r2 = 1000; ua2 = (3.33/1024*IntVolt); raport_divizor = ((r1+r2)/r2); voltage = ((ua2*raport_divizor) + 0.4); //0.4 means diode dropout return (float)(voltage); } float convert_cur (float IntCur){ // ------------------------Current conversion float current,Usunt,factor_op_amp,r2_op,r1_op,rs; r1_op = 1000; r2_op = 10000; rs = 0.020; factor_op_amp = (1+(r2_op/r1_op)); Usunt = ((3.33/1024*IntCur)/factor_op_amp); current = ((Usunt/rs)-0.03); if (current < 0.05) { current = 0; } return (float)(current); } float convert_btemp (float IntBtemp){ // ------------------------Board temp conversion float temperature,Ua1,r1_tb,r2_tb,t2k,rdiv; rdiv = 10500; r1_tb = 9900; Ua1 = (3.3/1024*IntBtemp); r2_tb = (3.3*rdiv/Ua1-rdiv); //r2 = vcc*rdiv/uADCin -rdiv if (r2_tb == r1_tb ){ r2_tb++;} // prevents log(1) t2k= ( (298.16*3380)/log(r1_tb/r2_tb) ) / (3380/log(r1_tb/r2_tb)-298.16); //T2= T1*B/ln(R1/R2) / ( B/ln(R1/R2) - T1 ) in Kelvin temperature = t2k - 273.16 ; return (float)(temperature); } float convert_ttemp (float IntTtemp){ // ------------------------Tip temp conversion float Ttemp,r1_opt,r2_opt,factor_op_temp,Ut_2; r1_opt = 500; r2_opt = 47000; factor_op_temp = (1+(r2_opt/r1_opt)); Ut_2 = ((3.33/1024)*IntTtemp); Ttemp = (((Ut_2/factor_op_temp)/0.000021)/10); // C Type Thermocouple has about 21uV/*C at 1000*C return (float)(Ttemp); } int debouncing_but (int){ //------------------------debouncing for sw release delay_time(500); do{ temp2 = P3IN; buton = (temp2 &= 0x01); }while (buton == 0); return(int)( buton ); } int debouncing_la_actionare_rotire(int rotE){ //------------debouncing for encoder rotation begin delay_time(500); do { temp2 = P3IN; rotE = (temp2 &= (BIT1 + BIT2)); temp2 = P3IN; buton = (temp2 &= 0x01); }while ((rotE == 6) and (buton != 0)); return (int)(rotE); } int debouncing_la_revenire_rotire(int rotE){ //-------debouncing for encoder rotation end delay_time(500); do { temp2 = P3IN; rotE = (temp2 &= (BIT1 + BIT2)); temp2 = P3IN; buton = (temp2 &= 0x01); }while ((rotE != 6) and (buton != 0)); return (int)(rotE); } void write_flash_data(int){ int *Flash_ptr; // Flash pointer Flash_ptr = (int *) 0x100F; // Initialize Flash pointer __disable_interrupt(); while(BUSY & FCTL3); // Check if Flash being used FCTL2 = FWKEY + FSSEL_1 + FN3; // Clk = SMCLK/4 FCTL3 = FWKEY; // Clear Lock bit FCTL1 = FWKEY + ERASE; // Set Erase bit *Flash_ptr = Clear; // Dummy write to erase Flash segment while(BUSY & FCTL3); // Check if Flash being used FCTL3 = FWKEY; // Clear Lock bit FCTL1 = FWKEY + WRT; // Set WRT bit for write operation *Flash_ptr++ = temp_preset; // Write value to flash *Flash_ptr++ = low_temp_preset; // Write value to flash *Flash_ptr++ = time_hot_preset; // Write value to flash *Flash_ptr++ = sound_preset; // Write value to flash *Flash_ptr++ = light_preset; // Write value to flash FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCK; // Set LOCK bit __enable_interrupt(); } void read_flash_data(int){ int *Flash_ptrC; // Segment C pointer Flash_ptrC = (int *) 0x100F; // Initialize Flash segment C pointer temp_preset = *Flash_ptrC++; // value stored in Flash_ptrC low_temp_preset = *Flash_ptrC++; // value stored in Flash_ptrC time_hot_preset = *Flash_ptrC++; // value stored in Flash_ptrC sound_preset = *Flash_ptrC++; // value stored in Flash_ptrC light_preset = *Flash_ptrC++; // value stored in Flash_ptrC } void configure_lcd(int){ //-----------------------------LCD-SET-AND-CONFIGURE--------------------------------------- for(i=0; i<14; i++){ strobe_data_p2(array_LCD_config_string[i]); } create_custom_char(0); } float bucla_div_mod(float ref_temp_val){ //---------------------------- Loop for div/mod ------------ unsigned char j; for(i=0; i<4; i++){ array_div_mod[i] = Clear; } for(j=0; j<4; j++){ if(j > 0){ ref_temp_val = ref_temp_val*10; } for(i=0; i<10; i++){ if ( ref_temp_val >= 10 ){ ref_temp_val = ref_temp_val - 10; array_div_mod[j] ++; } } } return (int)(array_div_mod); } void move_cursor_xy (int x,int y){ // ---------------------------- Display procedure------------ unsigned char adress,temp; adress = (127 + x + (64 * (y - 1))); //internal map correction temp = adress; P2OUT = Clear ; // R/W = 0 (write mode) RS = 0 (address) delay_time(500); adress = adress >> 4; adress = adress << 2; strobe_data_p2(adress); adress = temp; adress &= 0x0F; adress = adress << 2; strobe_data_p2(adress); } void display_char(unsigned char ch){ //------------- Display char------------------------ unsigned char temp; temp = ch; P2OUT = RS ; // R/W = 0 (write mode) RS = 1 (data) ch = ch >> 4; ch = ch << 2; strobe_data_p2(RS+ch); ch = temp; ch &= 0x0F; ch = ch << 2; strobe_data_p2(RS+ch); } void create_custom_char(int){ // --------------------------- create custom char----------- strobe_data_p2(D6); strobe_data_p2(Clear); // comand xxxxxxxxx means >> 0x40 comand set CGRAM adress to 0 for(i=0; i<80; i++){ strobe_data_p2(array_special_char[i]); } } void strobe_data_p2(int strobe){ // -------------------------- strobe data to display------------- P2OUT = (strobe); // data sent from comand delay_time(2000); P2OUT |= EN; // Enable = 1 delay_time(2000); P2OUT &= ~(EN); // Enable = 0 delay_time(2000); } void cls(int line){ // ---------------------- Clear seective screen areas------------- //0 means the entire screen, 1 means first row only and 2 means 2nd row only if((line == 0) or (line == 1)){ move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(' '); } } if((line == 0) or (line == 2)){ move_cursor_xy(1,2); for(i=0;i<8;i++){ display_char(' '); } } } void draw_Logo(int){ // -------------------- Logo intro------------- move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_logo1[i]); } move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_logo1[i]); } delay_extra_long(0); move_cursor_xy(1,1); for(i=16;i<24;i++){ display_char(bck_ground_logo1[i]); } move_cursor_xy(1,2); for(i=24;i<32;i++){ display_char(bck_ground_logo1[i]); } delay_extra_long(0); } void draw_main_menu_screen(int){ // --------------------------draw main menu------------- move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_main[i]); } move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_main[i]); } } void draw_solder_screen(int){ // -----------------draw the solder menu------------- move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_solder[i]); } move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_solder[i]); } } void draw_low_temp_screen(int){ // --------------draw stand by temperature adjust menu------------- move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_low[i]); } move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_up[i]); } } void draw_hi_temp_screen(int){ // --------------draw stand by temperature adjust menu------------- move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_up[i]); } move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_up[i]); } } void draw_time_hot_screen(int){ //-----------draw adjusting time before entering stand by menu------------- move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_time[i]); } move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_up[i]); } } void draw_sound_screen(int){ // -------------------draw sound menu------------- move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_sound[i]); } move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_up[i]); } } void draw_light_screen(int){ // ----------------draw back light menu------------- move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_light[i]); } move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_up[i]); } } void draw_default(int){ // -----------------------draw default menu------------- move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_default[i]); } move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_info[i]); } } void draw_info_screen(int){ // ------------------draw info screen menu------------- move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_info[i]); } move_cursor_xy(1,2); for(i=8;i<16;i++){ display_char(bck_ground_up[i]); } } void draw_sub_solder(int){ // -------------------draw sub solder menu------------- cls(0); move_cursor_xy(1,1); for(i=0;i<8;i++){ display_char(bck_ground_subsolder[i]); } } void draw_sub_solder_mm(int){ // ----------------------draw return to Main Menu------------- move_cursor_xy(1,2); for(i=0;i<8;i++){ display_char(bck_ground_retmain[i]); } } void draw_sub_solder_ret(int){ // ---------------------draw return to sub solder------------- move_cursor_xy(1,2); for(i=0;i<8;i++){ display_char(bck_ground_retsol[i]); } } void beep_lf(int beep_l,int beep_f){ // --------------------beep procedure------------- if (sound_preset > 0){ beep_l = (beep_l*sound_preset); beep_f = (beep_f/sound_preset); do{ P1OUT |= BIT7; // beeper = 1 delay_time(beep_f); P1OUT &= ~(BIT7); // beeper = 0 delay_time(beep_f); beep_l--; }while(beep_l != 0); } }